package com.ruoyi.mall.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mall.domain.MallTimeWithdraw;
import com.ruoyi.mall.service.IMallTimeWithdrawService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 返佣提现Controller
 * 
 * @author ruoyi
 * @date 2022-03-03
 */
@RestController
@RequestMapping("/mall/mallTimeWithdraw")
public class MallTimeWithdrawController extends BaseController
{
    @Autowired
    private IMallTimeWithdrawService mallTimeWithdrawService;

    /**
     * 查询返佣提现列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWithdraw:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallTimeWithdraw mallTimeWithdraw)
    {
        startPage();
        List<MallTimeWithdraw> list = mallTimeWithdrawService.selectMallTimeWithdrawList(mallTimeWithdraw);
        return getDataTable(list);
    }

    /**
     * 导出返佣提现列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWithdraw:export')")
    @Log(title = "返佣提现", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallTimeWithdraw mallTimeWithdraw)
    {
        List<MallTimeWithdraw> list = mallTimeWithdrawService.selectMallTimeWithdrawList(mallTimeWithdraw);
        ExcelUtil<MallTimeWithdraw> util = new ExcelUtil<MallTimeWithdraw>(MallTimeWithdraw.class);
        return util.exportExcel(list, "返佣提现数据");
    }

    /**
     * 获取返佣提现详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWithdraw:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallTimeWithdrawService.selectMallTimeWithdrawById(id));
    }

    /**
     * 新增返佣提现
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWithdraw:add')")
    @Log(title = "返佣提现", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallTimeWithdraw mallTimeWithdraw)
    {
        return toAjax(mallTimeWithdrawService.insertMallTimeWithdraw(mallTimeWithdraw));
    }

    /**
     * 修改返佣提现
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWithdraw:edit')")
    @Log(title = "返佣提现", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallTimeWithdraw mallTimeWithdraw)
    {
        return toAjax(mallTimeWithdrawService.updateMallTimeWithdraw(mallTimeWithdraw));
    }

    /**
     * 删除返佣提现
     */
    @PreAuthorize("@ss.hasPermi('mall:mallTimeWithdraw:remove')")
    @Log(title = "返佣提现", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallTimeWithdrawService.deleteMallTimeWithdrawByIds(ids));
    }
}
